home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
- Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
- Begin VB.Form pdfmain
- Caption = "FyTek's Text to PDF Converter - Sample Application"
- ClientHeight = 7515
- ClientLeft = 165
- ClientTop = 735
- ClientWidth = 7695
- LinkTopic = "Form1"
- ScaleHeight = 7515
- ScaleWidth = 7695
- StartUpPosition = 3 'Windows Default
- Begin VB.CheckBox fntItalic
- Caption = "Italics"
- Height = 255
- Left = 6240
- TabIndex = 8
- Top = 5520
- Width = 975
- End
- Begin VB.CheckBox fntBold
- Caption = "Bold"
- Height = 255
- Left = 6240
- TabIndex = 7
- Top = 5160
- Width = 975
- End
- Begin VB.ComboBox numCols
- Height = 315
- ItemData = "pdfmain.frx":0000
- Left = 1560
- List = "pdfmain.frx":000D
- Style = 2 'Dropdown List
- TabIndex = 4
- Top = 5640
- Width = 2055
- End
- Begin VB.ComboBox fntAlign
- Height = 315
- ItemData = "pdfmain.frx":0031
- Left = 1560
- List = "pdfmain.frx":0041
- Style = 2 'Dropdown List
- TabIndex = 3
- Top = 5160
- Width = 2055
- End
- Begin VB.ComboBox fntPoint
- Height = 315
- ItemData = "pdfmain.frx":0063
- Left = 5040
- List = "pdfmain.frx":009D
- Style = 2 'Dropdown List
- TabIndex = 6
- Top = 5640
- Width = 1095
- End
- Begin VB.ComboBox fntNum
- Height = 315
- ItemData = "pdfmain.frx":00D7
- Left = 4080
- List = "pdfmain.frx":00E4
- Style = 2 'Dropdown List
- TabIndex = 5
- Top = 5160
- Width = 2055
- End
- Begin VB.CheckBox chkPreview
- Caption = "Preview"
- Height = 375
- Left = 4080
- TabIndex = 9
- Top = 6480
- Value = 1 'Checked
- Width = 1335
- End
- Begin MSComctlLib.ImageList ImageList1
- Left = 360
- Top = 5040
- _ExtentX = 1005
- _ExtentY = 1005
- BackColor = -2147483643
- ImageWidth = 16
- ImageHeight = 16
- MaskColor = 12632256
- _Version = 393216
- BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
- NumListImages = 3
- BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "pdfmain.frx":0109
- Key = ""
- EndProperty
- BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "pdfmain.frx":0225
- Key = ""
- EndProperty
- BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "pdfmain.frx":033D
- Key = ""
- EndProperty
- EndProperty
- End
- Begin MSComctlLib.Toolbar Toolbar1
- Align = 1 'Align Top
- Height = 570
- Left = 0
- TabIndex = 16
- Top = 0
- Width = 7695
- _ExtentX = 13573
- _ExtentY = 1005
- ButtonWidth = 873
- ButtonHeight = 953
- Appearance = 1
- Style = 1
- ImageList = "ImageList1"
- _Version = 393216
- BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
- NumButtons = 5
- BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "New"
- ImageIndex = 1
- EndProperty
- BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
- ImageIndex = 2
- Style = 3
- EndProperty
- BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "Open"
- ImageIndex = 2
- EndProperty
- BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "Save"
- ImageIndex = 3
- EndProperty
- BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- EndProperty
- End
- Begin VB.TextBox txtEditor
- BeginProperty Font
- Name = "Courier New"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 3315
- Left = 5
- MultiLine = -1 'True
- ScrollBars = 3 'Both
- TabIndex = 11
- Top = 660
- Width = 6900
- End
- Begin VB.TextBox infile
- Height = 285
- Left = 1560
- TabIndex = 1
- Top = 4260
- Width = 5415
- End
- Begin VB.CommandButton cmdInput
- Caption = "..."
- Height = 255
- Left = 1200
- TabIndex = 12
- Top = 4260
- Width = 315
- End
- Begin MSComctlLib.StatusBar StatusBar1
- Align = 2 'Align Bottom
- Height = 375
- Left = 0
- TabIndex = 14
- Top = 7140
- Width = 7695
- _ExtentX = 13573
- _ExtentY = 661
- _Version = 393216
- BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
- NumPanels = 1
- BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
- Object.Width = 8819
- MinWidth = 8819
- EndProperty
- EndProperty
- End
- Begin MSComDlg.CommonDialog CommonDialog1
- Left = 960
- Top = 5040
- _ExtentX = 847
- _ExtentY = 847
- _Version = 393216
- End
- Begin VB.CommandButton cmdOutput
- Caption = "..."
- Height = 255
- Left = 1200
- TabIndex = 13
- Top = 4680
- Width = 315
- End
- Begin VB.CommandButton go
- Caption = "Create PDF"
- Height = 375
- Left = 2520
- TabIndex = 10
- Top = 6480
- Width = 1335
- End
- Begin VB.TextBox outfile
- Height = 285
- Left = 1560
- TabIndex = 2
- Top = 4680
- Width = 5415
- End
- Begin VB.Label fntLabel
- Alignment = 1 'Right Justify
- Caption = "Point Size"
- Height = 255
- Left = 4080
- TabIndex = 17
- Top = 5670
- Width = 855
- End
- Begin VB.Label lab_infile
- Alignment = 1 'Right Justify
- Caption = "Input File"
- Height = 255
- Left = 120
- TabIndex = 15
- Top = 4260
- Width = 975
- End
- Begin VB.Label lab_outfile
- Alignment = 1 'Right Justify
- Caption = "Output File"
- Height = 255
- Left = 120
- TabIndex = 0
- Top = 4680
- Width = 975
- End
- Begin VB.Menu mnuFile
- Caption = "&File"
- Begin VB.Menu mnuNewScript
- Caption = "&New Script"
- End
- Begin VB.Menu mnuOpenScript
- Caption = "&Open Script"
- End
- Begin VB.Menu mnuSpacer1
- Caption = "-"
- End
- Begin VB.Menu mnuSave
- Caption = "&Save"
- End
- Begin VB.Menu mnuSaveAs
- Caption = "Save &As"
- End
- Begin VB.Menu mnuSpacer2
- Caption = "-"
- End
- Begin VB.Menu mnuCreatePDF
- Caption = "&Create PDF"
- End
- Begin VB.Menu mnuSpacer3
- Caption = "-"
- End
- Begin VB.Menu Exit
- Caption = "E&xit"
- End
- End
- Attribute VB_Name = "pdfmain"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Public CancelUnload As Boolean
- Private Sub cmdInput_Click()
- OpenScript
- End Sub
- Private Sub cmdOutput_Click()
- CommonDialog1.DefaultExt = ".txt"
- CommonDialog1.Filter = "Adobe Acrobat|*.pdf"
- CommonDialog1.ShowOpen
- outfile.Text = CommonDialog1.FileName
- End Sub
- Private Sub Exit_Click()
- Unload Me
- End Sub
- Private Sub Form_Load()
- bolScriptNeedsSaving = False
- Toolbar1.Buttons(4).Enabled = False
- fntAlign.ListIndex = 0
- fntNum.ListIndex = 0
- fntPoint.ListIndex = 3
- numCols.ListIndex = 0
- End Sub
- Private Sub Form_Resize()
- txtEditor.Width = pdfmain.Width - 100
- End Sub
- Public Sub Form_Unload(Cancel As Integer)
- CheckForSave
- If CancelUnload Then Cancel = 1
- End Sub
- Private Sub go_Click()
- CreatePDF
- End Sub
- Public Sub OpenScript()
- CommonDialog1.InitDir = App.Path
- CommonDialog1.DefaultExt = ".txt"
- CommonDialog1.Filter = "Text Files|*.txt"
- CommonDialog1.ShowOpen
- If CommonDialog1.FileName = "" Then Exit Sub
- strScriptFilePath = CommonDialog1.FileName
- infile.Text = strScriptFilePath
- StatusBar1.Panels(1).Text = "Opening " & infile.Text
- If Not (FileSys.FileExists(infile.Text)) Then
- MsgBox "File does not exist"
- Exit Sub
- End If
- Open infile.Text For Input As #1
- Do Until EOF(1)
- Line Input #1, strLineInput
- If Not EOF(1) Then
- strFileInput = strFileInput & strLineInput & vbCrLf
- Else
- strFileInput = strFileInput & strLineInput
- End If
- Close #1
- StatusBar1.Panels(1).Text = ""
- txtEditor.Text = strFileInput
- bolScriptNeedsSaving = False
- Toolbar1.Buttons(4).Enabled = False
- End Sub
- Public Sub SaveScript()
- If Not (FileSys.FileExists(infile.Text)) Then
- CommonDialog1.InitDir = App.Path
- CommonDialog1.DefaultExt = ".txt"
- CommonDialog1.Filter = "Text Files|*.txt"
- CommonDialog1.ShowOpen
- End If
- If CommonDialog1.FileName = "" Then Exit Sub
- strScriptFilePath = CommonDialog1.FileName
- infile.Text = strScriptFilePath
- FileSys.DeleteFile (strScriptFilePath)
- StatusBar1.Panels(1).Text = "Saving " & strScriptFilePath
- Open strScriptFilePath For Binary As #1
- Put #1, , txtEditor.Text
- Close #1
- bolScriptNeedsSaving = False
- Toolbar1.Buttons(4).Enabled = False
- StatusBar1.Panels(1).Text = ""
- End Sub
- Private Sub mnuCreatePDF_Click()
- CreatePDF
- End Sub
- Private Sub mnuNewScript_Click()
- NewScript
- End Sub
- Private Sub mnuOpenScript_Click()
- OpenScript
- End Sub
- Private Sub PDF_Error(errCode As Long, errDesc As String)
- MsgBox "PDFCreator.dll error #" & errCode & vbCrLf & _
- errDesc
- End Sub
- Private Sub mnuSave_Click()
- SaveScript
- End Sub
- Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
- Select Case Button.Index
- Case 1
- NewScript
- Case 3 ' Open Button
- OpenScript
- Case 4
- SaveScript
- End Select
- End Sub
- Private Sub txtEditor_Change()
- If bolScriptNeedsSaving = True Then
- Exit Sub
- bolScriptNeedsSaving = True
- Toolbar1.Buttons(4).Enabled = True
- End If
- End Sub
- Private Sub NewScript()
- Dim intResult As Integer
- CheckForSave
- txtEditor.Text = ""
- bolScriptNeedsSaving = False
- Toolbar1.Buttons(4).Enabled = False
- End Sub
- Public Sub CheckForSave()
- ' If the script needs to be saved, then prompt the user
- ' otherwise, simply continue on to clearing the
- ' text box
- CancelUnload = False
- If bolScriptNeedsSaving = True Then
- intResult = MsgBox("Do you want to save your current script?", vbYesNoCancel, "Script needs saving")
- If intResult = vbCancel Then
- CancelUnload = True
- Exit Sub
- ElseIf intResult = vbYes Then
- SaveScript
- End If
- End If
- End Sub
- Public Sub CreatePDF()
- If txtEditor.Text = "" Then
- Exit Sub
- End If
- Dim PDF
- Set PDF = CreateObject("build.Fytek.PDF")
- strPDFFilePath = FormatFileName(Trim(outfile.Text))
- PDF.setOutFile (strPDFFilePath)
- fntFace = fntNum.ItemData(fntNum.ListIndex)
- If fntBold = 1 Then
- fntFace = fntFace + 3
- End If
- If fntItalic = 1 Then
- fntFace = fntFace + 6
- End If
- PDF.setColumns (numCols.ListIndex + 1)
- PDF.setColSpacing (0.5)
- PDF.setAlignment (Mid(fntAlign.List(fntAlign.ListIndex), 1, 1))
- PDF.setPointSize (fntPoint.ItemData(fntPoint.ListIndex))
- PDF.setFontNum (fntFace)
- Me.MousePointer = vbHourglass
- StatusBar1.Panels(1).Text = "Creating PDF File"
- ' Split the string up into individual lines in an array
- strScriptArray = Split(txtEditor.Text, vbCrLf)
- For i = 0 To UBound(strScriptArray)
- PDF.setPDFCmd (strScriptArray(i))
- retval = PDF.buildFytekPDF
- Me.MousePointer = vbNormal
- If chkPreview.Value = vbChecked Then
- StatusBar1.Panels(1).Text = "Opening Adobe Acrobat"
- frmPDFPreview.Pdf1.src = strPDFFilePath
- frmPDFPreview.Show
- StatusBar1.Panels(1).Text = ""
- End If
- Set PDF = Nothing
- End Sub
-